﻿using JoeyLibs.IdleStartMenu.Model;
using JoeyLibs.Utility.Log;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;

namespace JoeyLibs.IdleStartMenu.WPFUI
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
        }

        void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            if (e.ExceptionObject is IdleException)
            {
                IdleException exception = e.ExceptionObject as IdleException;
                new ExceptionLogModel(exception.Message, exception.Reason, exception.Solution, exception).Output();
            }
            else if (e.ExceptionObject is Exception)
            {
                Exception exception = e.ExceptionObject as Exception;
                new ExceptionLogModel(message:exception.Message, exception:exception).Output();
            }
        }
    }
}
